using System;
using System.Globalization;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ns20;

namespace ns16
{
	internal class Class90 : IFormatterConverter
	{
		private readonly JsonSerializer jsonSerializer_0;

		public Class90(JsonSerializer serializer)
		{
			Class204.smethod_2(serializer, "serializer");
			jsonSerializer_0 = serializer;
		}

		private T method_0<T>(object object_0)
		{
			Class204.smethod_2(object_0, "value");
			JValue jValue = (JValue)object_0;
			return (T)System.Convert.ChangeType(jValue.Value, typeof(T), CultureInfo.InvariantCulture);
		}

		public object Convert(object value, Type type)
		{
			Class204.smethod_2(value, "value");
			JToken jToken = value as JToken;
			if (jToken == null)
			{
				throw new ArgumentException("Value is not a JToken.", "value");
			}
			return jsonSerializer_0.Deserialize(jToken.CreateReader(), type);
		}

		public object Convert(object value, TypeCode typeCode)
		{
			Class204.smethod_2(value, "value");
			if (value is JValue)
			{
				value = ((JValue)value).Value;
			}
			return System.Convert.ChangeType(value, typeCode, CultureInfo.InvariantCulture);
		}

		public bool ToBoolean(object value)
		{
			return method_0<bool>(value);
		}

		public byte ToByte(object value)
		{
			return method_0<byte>(value);
		}

		public char ToChar(object value)
		{
			return method_0<char>(value);
		}

		public DateTime ToDateTime(object value)
		{
			return method_0<DateTime>(value);
		}

		public decimal ToDecimal(object value)
		{
			return method_0<decimal>(value);
		}

		public double ToDouble(object value)
		{
			return method_0<double>(value);
		}

		public short ToInt16(object value)
		{
			return method_0<short>(value);
		}

		public int ToInt32(object value)
		{
			return method_0<int>(value);
		}

		public long ToInt64(object value)
		{
			return method_0<long>(value);
		}

		public sbyte ToSByte(object value)
		{
			return method_0<sbyte>(value);
		}

		public float ToSingle(object value)
		{
			return method_0<float>(value);
		}

		public string ToString(object value)
		{
			return method_0<string>(value);
		}

		public ushort ToUInt16(object value)
		{
			return method_0<ushort>(value);
		}

		public uint ToUInt32(object value)
		{
			return method_0<uint>(value);
		}

		public ulong ToUInt64(object value)
		{
			return method_0<ulong>(value);
		}
	}
}
